// 关卡难度枚举
const LevelDifficulty = {
    EASY: 1,
    NORMAL: 2,
    HARD: 3,
    EXPERT: 4
};

// 节点类型枚举
const NodeType = {
    ENCOUNTER: 'encounter',  // 奇遇
    SHOP: 'shop',           // 商店
    BATTLE: 'battle',       // 战斗
    EVENT: 'event'          // 事件
};

// 关卡节点类
class LevelNode {
    constructor(type, difficulty, content) {
        this.type = type;           // 节点类型
        this.difficulty = difficulty; // 节点难度
        this.content = content;      // 节点内容
        this.children = [];          // 子节点
        this.x = 0;                 // 节点在地图上的X坐标
        this.y = 0;                 // 节点在地图上的Y坐标
    }

    addChild(node) {
        this.children.push(node);
    }
}

// 难度过滤器链
class DifficultyFilter {
    constructor(difficulty) {
        this.difficulty = difficulty;
        this.nextFilter = null;
    }

    setNext(filter) {
        this.nextFilter = filter;
        return filter;
    }

    filter(elements) {
        const filtered = elements.filter(element => 
            element.difficulty <= this.difficulty
        );

        if (this.nextFilter) {
            return this.nextFilter.filter(filtered);
        }
        return filtered;
    }
} 